/*
 * @Author: yuki
 * @Date: 2025-11-06 15:41:39
 * @LastEditTime: 2025-11-06 15:43:09
 * @Description: 验证用户id是否是正整数
 */
import { PipeTransform, Injectable, BadRequestException } from '@nestjs/common';

@Injectable()
export class IdValidatePipe implements PipeTransform {
  transform(value: string) {
    const id = parseInt(value, 10);
    if (isNaN(id) || id <= 0) {
      throw new BadRequestException('用户id必须是正整数');
    }
    return id;
  }
}
